package com.tang.algorithm.ordinary;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @author tlm
 * @version 1.0
 * @date 2020/5/31 20:14
 * 拥有最多糖果的孩子
 * https://leetcode-cn.com/problems/kids-with-the-greatest-number-of-candies/
 */
public class LeetCode1431 {
    public static void main(String[] args) {
        int[] a = {2, 3, 5, 1, 3};
        kidsWithCandies(a, 3).forEach(s -> System.out.println(s));
    }

    public static List<Boolean> kidsWithCandies(int[] candies, int extraCandies) {
        int max = 0;
        for (int i = 0; i < candies.length; i++) {
            max = Math.max(max, candies[i]);
        }
        List<Boolean> list = new ArrayList<>();
        for (int i = 0; i < candies.length; i++) {
            if (candies[i] + extraCandies >= max) list.add(true);
            else list.add(false);
        }
        return list;
    }
}
